<template>
  <div>
    <router-link to="/banner" style="color:black;text-decoration:none;float:left;margin-top:20px">
      <el-button type="success">
        添加
        <i class="el-icon-arrow-right"></i>
      </el-button>
    </router-link>

    <el-table
      :data="tableData"
      style="width: 100%"
      :default-sort="{prop: 'date', order: 'descending'}"
    >
      <el-table-column prop="id" label="id" sortable width="80"></el-table-column>
      <el-table-column prop="productIndex" label="种类" sortable width="100"></el-table-column>
      <el-table-column prop="gyqy" label="供应企业" sortable width="110"></el-table-column>
      <el-table-column prop="gydz" label="供应地址" sortable width="200"></el-table-column>
      <el-table-column prop="cpgg" label="产品规格" sortable width="200"></el-table-column>
      <el-table-column label="图片">
        <template slot-scope="scope">
          <img :src="scope.row.hyd_img" style="height: 50px" />
        </template>
      </el-table-column>
      <el-table-column prop="frl" sortable label="发热量" width="100"></el-table-column>
      <el-table-column prop="gdt" sortable label="固定碳" width="100"></el-table-column>
      <el-table-column prop="liu" sortable label="硫" width="100"></el-table-column>
      <el-table-column prop="huifa" sortable label="挥发" width="100"></el-table-column>
      <el-table-column prop="shuifen" sortable label="水分" width="100"></el-table-column>
      <el-table-column prop="huifen" sortable label="灰分" width="100"></el-table-column>
      <el-table-column prop="title" sortable label="标题" width="100"></el-table-column>
      <el-table-column label="产品图片">
        <template slot-scope="scope">
          <img :src="scope.row.cp_img" style="height: 50px" />
        </template>
      </el-table-column>
      <el-table-column prop="cp_video" sortable label="产品视频连接" width="350"></el-table-column>
      <el-table-column prop="kc" sortable label="库存" width="100"></el-table-column>
      <el-table-column prop="price" sortable label="价格" width="100"></el-table-column>
      <el-table-column prop="cpjs" sortable label="产品介绍" width="550"></el-table-column>
      <el-table-column prop="qyjs" sortable label="企业介绍" width="650"></el-table-column>
      <el-table-column label="企业图片">
        <template slot-scope="scope">
          <img :src="scope.row.qiye_img" style="height: 50px" />
        </template>
      </el-table-column>
      <el-table-column label="营业执照">
        <template slot-scope="scope">
          <img :src="scope.row.yyzz_img" style="height: 50px" />
        </template>
      </el-table-column>
      <el-table-column prop="xydm" sortable label="信用代码" width="100"></el-table-column>
      <el-table-column prop="company_name" sortable label="公司名称" width="100"></el-table-column>
      <el-table-column prop="fddbr" sortable label="法定代表人" width="100"></el-table-column>
      <el-table-column prop="zhusuo" sortable label="住所" width="100"></el-table-column>
      <el-table-column prop="nsmc" sortable label="纳税名称" width="100"></el-table-column>
      <el-table-column prop="nsyh" sortable label="纳税银行" width="100"></el-table-column>
      <el-table-column prop="khzh" sortable label="开户帐号" width="100"></el-table-column>
      <el-table-column prop="nsdz" sortable label="纳税地址" width="100"></el-table-column>
      <el-table-column prop="nsdh" sortable label="纳税电话" width="100"></el-table-column>
      <el-table-column prop="created_at" sortable label="创建时间" width="100"></el-table-column>
      <el-table-column prop="updated_at" sortable label="更新时间" width="100"></el-table-column>
      <el-table-column prop="deleted_at" sortable label="删除时间" width="100"></el-table-column>
      <el-table-column label="操作" width="200">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            @click.native.prevent="deleteRow(scope.$index, tableData)"
          >删除</el-button>
          <el-button type="text" size="small" @click="toDetails(scope.$index, scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div>
      <el-pagination
        align="center"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="100"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  props: {},
  data() {
    return {
      tableData: [],
      currentPage: 1, // 当前页码
      pageSize: 5, // 每页的数据条数
      product_id: 1
    };
  },
  created() {
    this.axios({
      method: "post",
      url: "/wrd/cpfllb",
      params: {
        page: this.currentPage, //这是页码数。填写2数据不一样了
        address: 0,
        big_type_id: 1,
        cp_gy: 0,
        cp_gg: 0
      }
    }).then(res => {
      // console.log(res);
      this.tableData = res.data.data;
      console.log(this.tableData);
    });
  },
  methods: {
    handleClick(row) {
      console.log(row);
    },
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      // this.currentPage = 1;
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.currentPage = val;
      this.axios({
        method: "post",
        url: "/wrd/cpfllb",
        params: {
          page: this.currentPage, //这是页码数。填写2数据不一样了
          address: 0,
          big_type_id: 1,
          cp_gy: 0,
          cp_gg: 0
        }
      }).then(res => {
        // console.log(res);
        this.tableData = res.data.data;
        console.log(this.tableData);
      });
    },
    getUsers() {
      this.isShowloading = true;
      let params = {
        searchInfo: this.searchInfo.trim(),
        page: this.pageNo
      };
    },
    toDetails(index, row) {
      console.log(row);
      this.$router.push({
        path: "/cpxq",
        query: {
          product_id: row.id
        }
      });
    }
  }
};
</script>
<style  scoped>
</style>